home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / index.arc / AEBITFIN.BAS < prev    next >
Encoding:
BASIC Source File  |  1987-01-11  |  1.5 KB  |  56 lines

  1. rem $linesize:132
  2. rem $title:'Application Engineer Standard Routines'
  3. rem $subtitle:'Find a key in the index'
  4. '
  5. '  find a key in the index. if the find was a success, then two values
  6. '  are actually returned. success% holds the pointer to the physical
  7. '  position on the index, while mrec% returns the master record number.
  8. '  the find actually returns a match directly on the key being looked for.
  9. '  if there was no direct match, then ky$ will return the match before
  10. '  the return, mrec% will have a minus record number value, and success%
  11. '  will return the pointer into the index - for the bit.next and bit.prev
  12. '  routines to use.
  13. '
  14. '                Include the COMMON values
  15. rem $include:'AESHARED.BAS'            
  16.     
  17.  
  18. sub bit.find(fl%,ky$,mrec%,success%) static
  19.  
  20.         mrec%=0
  21.         success%=0
  22.         if len(ky$)<xh%(fl%,1) then
  23.             ky$=ky$+string$(xh%(fl%,1)-len(ky$),32)
  24.         end if
  25.         rrec%=1
  26.         loop%=0%
  27.  
  28.         while loop%=0%
  29.             prrec%=rrec%                              ' hold the recnum for eval
  30.             get #fl%,rrec%
  31.             if cvi(xk$(fl%,5))=0 then
  32.                 goto fplace                            ' this is end of chain
  33.             elseif ky$<xk$(fl%,1) then
  34.                 side%=2%
  35.             elseif ky$>xk$(fl%,1) then
  36.                 side%=3%
  37.             else
  38.                 success%=rrec%
  39.                 mrec%=cvi(xk$(fl%,5%))
  40.                 goto ffound
  41.             end if
  42.             rrec%=cvi(xk$(fl%,side%))
  43.             if rrec%=0% then
  44.                 goto fplace
  45.             end if
  46.         wend
  47.  
  48. fplace:
  49.         mrec%=-cvi(xk$(fl%,5))
  50.         success%=prrec%
  51.         ky$=xk$(fl%,1)
  52.  
  53. ffound:
  54.  
  55.     end sub
  56.